package cvcg.dao;

import java.io.Serializable;
import java.util.Collection;
import java.util.List;

import cvcg.dto.GameSessionVoteDTO;
import cvcg.model.Game;
import cvcg.model.GameSession;
import cvcg.model.Player;
import cvcg.model.Score;

public interface BaseDAO {
	/**
	 * Generic method used to get all objects of a particular type. This is the
	 * same as lookup up all rows in a table.
	 * 
	 * @param clazz
	 *            the type of objects (a.k.a. while table) to get data from
	 * @return List of populated objects
	 */
	@SuppressWarnings("rawtypes")
	List getObjects(Class clazz);

	/**
	 * Generic method to get an object based on class and identifier. An
	 * ObjectRetrievalFailureException Runtime Exception is thrown if nothing is
	 * found.
	 * 
	 * @param clazz
	 *            model class to lookup
	 * @param id
	 *            the identifier (primary key) of the class
	 * @return a populated object
	 * @see org.springframework.orm.ObjectRetrievalFailureException
	 */
	@SuppressWarnings("rawtypes")
	Object getObject(Class clazz, Serializable id);

	/**
	 * Generic method to save an object - handles both update and insert.
	 * 
	 * @param o
	 *            the object to save
	 */
	void saveObject(Object o);

	/**
	 * Generic method to save a list of object - handles both update and insert.
	 * 
	 * @param c
	 *            the collection to save
	 */
	@SuppressWarnings("rawtypes")
	void saveAll(Collection c);

	/**
	 * Generic method to delete an object based on class and id
	 * 
	 * @param clazz
	 *            model class to lookup
	 * @param id
	 *            the identifier of the class
	 */
	@SuppressWarnings("rawtypes")
	void removeObject(Class clazz, Serializable id);

	/**
	 * Generic method to remove a complete collection of entities.
	 * 
	 * @param entities
	 *            the collection to remove
	 */
	@SuppressWarnings("rawtypes")
	void removeAllObjects(Collection entities);
	
	Player getPlayerByName(String playerName);
	
	public List<GameSessionVoteDTO> getGameSessionVotes(final Long gameSessionId);
	
	/**
	 * @return next game session (in time)
	 */
	public GameSession getNextGameSession();
	
	public void flushSession();
	
	public List<GameSession> getGameSessionsByStatus(String status);
	
	public List<Score> getScoreByPlayerName(String playerName);
	
	public Score getScoreById(Long id);
	
	public List<Game> getAllGamesWithoutScore();
	
	public List<Game> getAllGamesOrderedByName() ;
}
